import axios, {InternalAxiosRequestConfig} from "axios";

export const JwtRequestInterceptor = (config: InternalAxiosRequestConfig<any>) => {
  const jwt = sessionStorage.getItem('Authorization');
  if (jwt) {
    config.headers.Authorization = 'Bearer ' + jwt;
  }
  return config;
};

export const enableJwtRequestInterceptor = () => {
  axios.interceptors.request.use(JwtRequestInterceptor);
}
